#include<iostream>
#include<vector>
using namespace std;
int main(){
	string s1,s2,s3;
	int i=0,j=1,n;
	vector<string> str1,str2,str3;
	getline(cin,s1);
	getline(cin,s2);
	getline(cin,s3);
	getchar();
	cin>>n;
	str1.push_back(" ");
	str2.push_back(" ");
	str3.push_back(" ");
	while(i<s1.size()&&j<s1.size()){
		while(s1[i]!='[') i++;
		while(s1[j]!=']') j++;
		str1.push_back(s1.substr(i+1,j-i-1));
		i=j+1;j++;
	}
	i=0,j=1;
	while(i<s2.size()&&j<s2.size()){
		while(s2[i]!='[') i++;
		while(s2[j]!=']') j++;
		str2.push_back(s2.substr(i+1,j-i-1));
		i=j+1;j++;
	}
	i=0,j=1;
	while(i<s3.size()&&j<s3.size()){
		while(s3[i]!='[') i++;
		while(s3[j]!=']') j++;
		str3.push_back(s3.substr(i+1,j-i-1));
		i=j+1;j++;
	}
	cout<<str1.size(); 
//	for(i=0;i<str1.size();i++)
//		cout<<str1[i]<<" ";
//	for(i=0;i<n;i++){
//		int a,b,c,d,e;
//		cin>>a>>b>>c>>d>>e;
//		if(a>str1.size()||b>str1.size()||c>str2.size()||d>str2.size()||e>str3.size())
//			cout<<"Are you kidding me? @\\/@"<<endl;	
//		else cout<<str1[a]<<str2[b]<<str3[c]<<str2[d]<<str1[e]<<endl;
//		
//	}
	return 0;
}
